import { Action } from 'redux'
import { createRequestTypes } from '@UTILS/reduxHelper'
import { StepRecordITF } from '@INTERFACES/DataCenter'
import {
  DataCenterActionITF,
  DataCenterDeleteLoggActionITF,
  DataCenterGetLogsActionITF,
  DataCenterGetMonthLogActionITF
} from '@REDUXITF/dataCenter'

export const GET_TODAY_PAIN_LOG = createRequestTypes('GET_TODAY_PAIN_LOG')
export const GET_TODAY_STEP = createRequestTypes('GET_TODAY_STEP')
export const SAVE_WECHAT_STEP_RECORDS = createRequestTypes('SAVE_WECHAT_STEP_RECORDS')
export const GET_LASTEST_EXPIRED_PLAN = createRequestTypes('GET_LASTEST_EXPIRED_PLAN')
export const GET_LOGS_BY_DATE_BUCKET = createRequestTypes('GET_LOGS_BY_DATE_BUCKET')
export const DELETE_LOG = createRequestTypes('DELETE_LOG')
export const GET_MONTH_LOG = createRequestTypes('GET_MONTH_LOG')

export default {
  dispatchSaveWeChatStepRecords(records: StepRecordITF[]): DataCenterActionITF {
    return {
      type: SAVE_WECHAT_STEP_RECORDS.REQUEST,
      records
    }
  },
  dispatchGetTodayStep(): Action {
    return {
      type: GET_TODAY_STEP.REQUEST
    }
  },
  dispatchGetTodayPainLog(): Action {
    return {
      type: GET_TODAY_PAIN_LOG.REQUEST
    }
  },
  dispatchGetMyLastestExpiredPlan(): Action {
    return {
      type: GET_LASTEST_EXPIRED_PLAN.REQUEST
    }
  },
  dispatchGetMyPainLogsByDateBucket(dateBucket: string): DataCenterGetLogsActionITF {
    return {
      type: GET_LOGS_BY_DATE_BUCKET.REQUEST,
      dateBucket
    }
  },
  dispatchDeleteLog(logId: string, bucket: string, pId: string): DataCenterDeleteLoggActionITF {
    return {
      type: DELETE_LOG.REQUEST,
      logId,
      bucket,
      pId
    }
  },
  dispatchGetPatientMonthPainLog(bucket: string, pId: string): DataCenterGetMonthLogActionITF {
    return {
      type: GET_MONTH_LOG.REQUEST,
      bucket,
      pId
    }
  }
}
